<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="java.util.Date"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="registration.js"></script>
  <%@ page import = "java.sql.Connection" %>
        <%@ page import = "java.sql.DriverManager" %>
        <%@ page import = "java.sql.ResultSet" %>
        <%@ page import = "java.sql.Statement" %>
        <%@ page import = "java.sql.SQLException" %>
        <%@ page import = "java.sql.Connection" %>
 	<title>SDU registration page</title>
	<link rel="shortcut icon" type="image/x-icon" href="Images/favicon.ico">
 
</head>
<body>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/study", "root", "");
Statement st = connection.createStatement();
ResultSet rs;
String sql;
%>
 			<div class="mainLogo" >
            <a href="" id="logo">
            	<span>
            		<img style="margin-top:-5px;" width="60px" height="30px" src="${pageContext.request.contextPath}/Images/s5_logo.png">
            	</span>
            </a>
            </div>
<div class="header">Registration page</div>
			<div id="div_error" class="div_error" style="display: none"><label id="label_error"></label></div>		
	<div >
	<form method="POST" action="register.jsp" >
	<table id="registration_table">

				<tr>
					<td><label>Last Name</label></td>
					<td><input type="text" name="lastname" id="lastname" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>First Name</label></td>
					<td><input type="text" name="firstname" id="firstname" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Patronymic</label></td>
					<td><input type="text" name="patronymic" id="patronymic" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Academic degree</label></td>
					<td>
					<select name="academicdegree" id="academicdegree">		
					<option value="0">Choose academic degree</option>				
					<%
					sql = "SELECT * FROM academicdegree";
					rs = st.executeQuery(sql);
					while(rs.next()){
						%>
						<option value="<%=rs.getInt("academicdegree_id") %>"><%=rs.getString("name_en") %></option>
						<%
					}
					%>
					</select>		
					</td>
				</tr>

				<tr>
					<td><label>Study form</label></td>
					<td>
					<div id="studyform_div">
						<select name="studyform" id="studyform">
						<option value="0">Choose study form</option>
					<%
					sql = "SELECT * FROM studyform";
					rs = st.executeQuery(sql);
					while(rs.next()){
						%>
						<option value="<%=rs.getInt("studyform_id") %>"><%=rs.getString("name_en") %></option>
						<%
					}
					%>
						</select>
					</div>
					</td>
				</tr>
				
				<tr>
					<td><label>Faculty</label></td>
					<td>
					<select name="faculty" id="faculty">	
					<option value="0">Choose faculty</option>					
					<%
					sql = "SELECT * FROM faculty";
					rs = st.executeQuery(sql);
					while(rs.next()){
						%>
						<option value="<%=rs.getInt("faculty_id") %>"><%=rs.getString("name_en") %></option>
						<%
					}
					%>
					
					
					</select>		
					</td>
				</tr>
				
				<tr>
					<td><label>Speciality</label></td>
					<td>
					<div id="speciality_div">
						<select name="speciality" id="speciality">
						<option value="0">Choose speciality</option>
					<%
					sql = "SELECT * FROM speciality";
					rs = st.executeQuery(sql);
					while(rs.next()){
						%>
						<option value="<%=rs.getInt("speciality_id") %>"><%=rs.getString("name_en") %></option>
						<%
					}
					%>
						</select>
					</div>
					</td>
				</tr>

				<tr>
					<td><label>Entry year</label></td>
					<td><input name="entry_year" type="text" size="50" maxlength="40" /></td>
				</tr>
				
				<tr>
					<td><label>Birthday</label></td>
					<td><input name="birthday" type="text" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>IIN</label></td>
					<td><input id="iin" name="iin" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				<tr>
					<td><label>Passport number</label></td>
					<td><input id="passport_number" name="passport_number" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				<tr>
					<td><label>by</label></td>
					<td><input id="idissuedby" name="idissuedby" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				<tr>
					<td><label>till</label></td>
					<td>
					<input name="idvalidbefore" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				
				<tr>
					<td><label>Sex</label></td>
					<td><input type="radio" id="sex" name="sex" value="1"/>male
					<input type="radio" id="sex" name="sex" value="2"/>female</td>
				</tr>
				<tr>
					<td><label>Address</label></td>
					<td><input id="address" name="address" type="text" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Phone number</label></td>
					<td><input id="tel" name="tel" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				<tr>
					<td><label>E-mail</label></td>
					<td><input id="mail" name="mail" type="text" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Previous study place</label></td>
					<td><input id="previousuniversity" name="previousuniversity" type="text" size="50" maxlength="40" />
					</td>
				</tr>

				<tr>
					<td><label>Year completed</label></td>
					<td><input id="yearcompleted" name="yearcompleted" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				<tr><td colspan="2"><b>Mother</b></td></tr>
				<tr>
					<td><label>Last Name</label></td>
					<td><input type="text" name="mother_lastname" id="mother_lastname" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>First Name</label></td>
					<td><input type="text" name="mother_firstname" id="mother_firstname" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Patronymic</label></td>
					<td><input type="text" name="mother_patronymic" id="mother_patronymic" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Address</label></td>
					<td><input id="mother_address" name="mother_address" type="text" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Phone number</label></td>
					<td><input id="mother_tel" name="mother_tel" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				
				<tr><td colspan="2"><b>Father</b></td></tr>
				<tr>
					<td><label>Last Name</label></td>
					<td><input type="text" name="father_lastname" id="father_lastname" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>First Name</label></td>
					<td><input type="text" name="father_firstname" id="father_firstname" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Patronymic</label></td>
					<td><input type="text" name="father_patronymic" id="father_patronymic" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Address</label></td>
					<td><input id="father_address" name="father_address" type="text" size="50" maxlength="40" /></td>
				</tr>
				<tr>
					<td><label>Phone number</label></td>
					<td><input id="father_tel" name="father_tel" type="text" size="50" maxlength="40" />
					</td>
				</tr>
				
				
				<tr>
      				<td>Load photo</td><td><input type="file" name="file" id="file" /></td>      				
      			</tr>
				<tr>
					<td></td>
					<td><input type="submit" name="studentAddFormSubmit" id="studentAddFormSubmit" value="Save" /></td>
				</tr>


	</table>
	</form>
	</div>
</body>
</html>